cmake_minimum_required(VERSION 3.16)

project(ControlX VERSION 0.1 LANGUAGES CXX)

# ==========================
# C++ 标准
# ==========================
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_BUILD_TYPE Debug)

# ==========================
# 查找 Qt6 Quick 模块
# ==========================
set(CMAKE_PREFIX_PATH "D:/QT6/6.9.1/mingw_64")
#set(CMAKE_PREFIX_PATH "/home/max-cos/Qt/6.9.2 /gcc_64")
find_package(Qt6 REQUIRED COMPONENTS Quick SerialPort Widgets PrintSupport Graphs GraphsWidgets Charts)

qt_standard_project_setup(REQUIRES 6.8)



# ==========================
# 可执行文件
# ==========================
qt_add_executable(appEvolveUI
        main.cpp
        Controller.cpp
        Controller.h
        Config.cpp
        Config.h
        CppInterface/Serial.cpp
        CppInterface/Serial.h
        CppInterface/StateManager.cpp
        CppInterface/StateManager.h
		CppInterface/UdpClient.cpp
		CppInterface/UdpClient.h
		CppInterface/DataProcessor.cpp
		CppInterface/DataProcessor.h
)

# ==========================
# QML 模块
# ==========================
qt_add_qml_module(appEvolveUI
        URI EvolveUI
        VERSION 1.0
        QML_FILES
        Dashboard.qml
        components/EButton.qml
        components/EInput.qml
        components/EList.qml
        components/EHoverCard.qml
        components/ETheme.qml
        components/ESwitchButton.qml
        components/ECheckBox.qml
        components/ERadioButton.qml
        components/ESlider.qml
        components/EBlurCard.qml
        components/ENavBar.qml
        components/ETimeDisplay.qml
        components/EAvatar.qml
        components/EAccordion.qml
        components/ECard.qml
        components/ECalendar.qml
        components/ECarousel.qml
        components/EClock.qml
        components/ECardWithTextArea.qml
        QML_FILES components/EDataTable.qml
        QML_FILES components/EAnimatedWindow.qml
        QML_FILES components/Aboutme.qml
        QML_FILES components/EDrawer.qml
        QML_FILES components/EDropdown.qml
        QML_FILES components/MessageDialog.qml
        QML_FILES components/ESerialInput.qml
        QML_FILES components/SerialMessageView.qml
        QML_FILES components/appendDataFromQml.qml
)

# ==========================
# Qt 资源文件
# ==========================
qt_add_resources(APP_RESOURCES
        src.qrc
)

target_sources(appEvolveUI PRIVATE ${APP_RESOURCES})

# ==========================
# 平台特定设置
# ==========================
# macOS / iOS Bundle 设置
set_target_properties(appEvolveUI PROPERTIES
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
)

# ==========================
# 链接 Qt 库
# ==========================
target_link_libraries(appEvolveUI
        PRIVATE Qt6::Quick
        Qt6::SerialPort
        Qt6::Widgets
		Qt6::PrintSupport
		Qt6::Graphs
		Qt6::GraphsWidgets
		Qt6::Charts
)

# ==========================
# 安装规则
# ==========================
include(GNUInstallDirs)
install(TARGETS appEvolveUI
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
